interface Friend {
  name: string;
  married?: boolean;
}

function sayHello2(friend: Friend): void {
  console.log('Hello, ' + friend.name);
  if(friend.married) {
    console.log("What's your partner's name?");
  }
  // if(friend.age >= 20) { // Friend不存在age属性
  //       // do something
  // }
}

let jack = {
  name: 'Jack'
}

let marry = {
  name: 'Marry',
  married: true
}

sayHello2(jack);
sayHello2(marry);